#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244853;
typedef long long LL;
const int N = 2e6 + 10;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> arr(m + 1);  
    vector<vector<int>> sets(n + 1); 
    for (int i = 1; i <= n; ++i) {
        int t;
        cin >> t;
        for (int j = 0; j < t; ++j) {
            int x;
            cin >> x;
            sets[i].push_back(x);
            arr[x]++;
        }
    }
    for (int i = 1; i <= m; ++i) {
        if (arr[i] == 0) {
            cout << "No\n";
            return;
        }
    }
    int count = 1;  
    for (int i = 1; i <= n; ++i) {
        bool can_remove = true;
        for (int x : sets[i]) {
            if (arr[x] <= 1) {
                can_remove = false;
                break;
            }
        }
        if (can_remove) {
            count++;
            if (count >= 3) { 
                cout << "Yes\n";
                return;
            }
        }
    }
    
    cout << "No\n";
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
}
/*

 */